//index.js
//获取应用实例
const app = getApp()
const getData = require('../../util/getData')
Page({
  data: {
    musics: []
  },
  async onLoad(){
    var res=await getData.getMusicData()
    this.handleData(res)
  },
  handleData: function (res) {
 
    var musics = []
    var music = res.data.playlists; 
    music.forEach(item => {
      var obj = {};
      obj.picUrl = item.coverImgUrl;
      obj.name = item.name;
      obj.id = item.id;
      musics.push(obj)
    })
    console.log(musics)
    this.setData({
      musics,
    })
  },
  handleMusicContent: function (event) {
    var { id } = event.currentTarget.dataset
    wx.navigateTo({
      url: '/pages/musicContent/musicContent?id=' + id,
    })
  }

})
